var index = 1;
var s=0;
var apa=0.3;

function auto_img(){
    index ++ ;
    if(index > 8){
        index = 1;
        s=8;
        document.getElementById("s"+s).className="null";        
    }
    var opa=0;
    var amtime=setInterval(animate,35);
    function animate(){
        if(opa>1){
            clearInterval(animate);
        }else{
            opa+=0.02;
            document.getElementById("wrap-img").style.opacity=opa;
        }
    }    
    var img = document.getElementById("wrap-img");
    img.src = "../images/pages/dex/slider-"+index+".jpg";    
    document.getElementById(("s"+index)).className="red_lock";
    document.getElementById("sliderwrap-bg").style.backgroundImage="url(../images/pages/dex/slider-"+index+"blur.jpg)";
    document.getElementById(("s"+[index-1])).className="null";
}

function right(){
    stop(auto_img());
    document.getElementById("wrap-img").src="../images/pages/dex/slider-"+index+".jpg";
    document.getElementById("s"+[index]).className="red_lock";
}

function left(){
    stop(auto_img());
    if(index==8){
        document.getElementById("wrap-img").src="../images/pages/dex/slider-7.jpg";
        document.getElementById("s7").className="red_lock";
        document.getElementById("s8").className="null";
    }else{
        --index;
        document.getElementById("wrap-img").src="../images/pages/dex/slider-"+(index-1)+".jpg";
        document.getElementById("s"+[index]).className="null";
        document.getElementById("s"+[index+1]).className="null";
        document.getElementById("s"+[index-1]).className="red_lock";
        index=[index-1];
    }
}

//2.定义定时器
setInterval(auto_img,3500);

window.onload=function(){
    document.getElementById("wrap-img").style.opacity="1";
}